package com.tanhua.server.controller;

import com.tanhua.server.service.BaiduService;
import org.apache.dubbo.common.serialize.protobuf.support.wrapper.MapValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/baidu")
public class BaiduController {

    @Autowired
    private BaiduService baiduService;

    //上报地理位置
    @PostMapping("/location")
    public ResponseEntity location(@RequestBody Map map) {
        //接收参数
        String lat = map.get("latitude").toString();
        Double latitude = Double.valueOf(lat);
        String lon = map.get("longitude").toString();
        Double longitude = Double.valueOf(lon);
        String addrStr = map.get("addrStr").toString();
        //保存
        baiduService.location(latitude, longitude, addrStr);
        //返回参数
        return ResponseEntity.ok(null);
    }


}
